{% extends "admin/base.html" %}
{% block ext_css %}
    <link href="{{ url_for('static',filename='ext/DataTables-1.10.3/media/css/jquery.dataTables.css') }}"
          rel="stylesheet"
          type="text/css">
{% endblock %}
{% block content %}
    <ol class="breadcrumb">
        <li><a href="#">后台</a></li>
        <li class="active">文章管理</li>
    </ol>
    <hr/>
    <div class="box-header well" data-original-title="">
        <h2><i class="glyphicon glyphicon-book red"></i> 文章管理</h2>
    </div>
    <div class="box-content">
        <table id="user" class="table display table-striped table-bordered  bootstrap-datatable datatable responsive">
            <thead>
            <tr>
                <th>标题</th>
                <th>类别</th>
                <th>是否公开</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tfoot>
            <tr>
                <th>标题</th>
                <th>类别</th>
                <th>是否公开</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            </tfoot>
            <tbody>
            {% for a in article %}
                <tr>
                    <td>
                        {% if a.title[20] %}
                            {{ a.title[:20]+'...' }}
                        {% else %}
                            {{ a.title }}
                        {% endif %}
                    </td>
                    <td class="center">{{ a.category.name }}</td>
                    {% if a.is_open == 1 %}
                        <td class="center-text">
                            <span class="label-success label label-default">公开</span>
                        </td>
                    {% else %}
                        <td class="center-text">
                            <span class="label-warning label label-default">不公开</span>
                        </td>
                    {% endif %}
                    <td class="center">{{ a.post_date }}</td>
                    <td class="center">
                        <a class="btn btn-success" href="{{ url_for('article.show',aid=a.id) }}">
                            <i class="glyphicon glyphicon-zoom-in icon-white"></i>
                            浏览
                        </a>
                        <a class="btn btn-info" href="{{ url_for('article.edit',id=a.id) }}">
                            <i class="glyphicon glyphicon-edit icon-white"></i>
                            编辑
                        </a>
                        <a class="btn btn-danger" data-trigger="confirm" href="{{ url_for('admin.articledelete',id=a.id) }}">
                            <i class="glyphicon glyphicon-trash icon-white"></i>
                            删除
                        </a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}
{% block script %}
    <script type="text/javascript" src="{{ url_for('static', filename='js/jquery/jquery-2.1.1.js') }}"></script>
    <script type="text/javascript"
            src="{{ url_for('static', filename='ext/DataTables-1.10.3/media/js/jquery.dataTables.js') }}"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#user').dataTable({
                stateSave: true
            });
        });
    </script>
{% endblock %}